package com.cke.yang.common.infra.enums;

import lombok.Getter;

/**
 * 保存操作的动作枚举
 *
 * @author yuyang
 * @date 2025-11-22 00:00:00
 */
@Getter
public enum SaveActionEnum {

    /**
     * 动作_删除
     */
    DELETE("delete"),

    /**
     * 动作_插入
     */
    INSERT("insert"),

    /**
     * 动作_更新
     */
    UPDATE("update");

    private final String code;

    SaveActionEnum(String code) {
        this.code = code;
    }

    public static boolean support(String code) {
        if (code == null) {
            return false;
        }
        for (SaveActionEnum action : SaveActionEnum.values()) {
            if (action.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

    public static SaveActionEnum getByCode(String code) {
        for (SaveActionEnum action : values()) {
            if (action.code.equals(code)) {
                return action;
            }
        }
        return null;
    }

}
